﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using System.Data;

namespace DuncanDAL
{
    public class EarningCategoryDataService:IDAL<D_EarningCategoryObject>
    {
        public const string SQL_SELECT_EARNINGCATEGORY = "select * from D_EarningCategory";
        public const string SQL_SELECT_SINGLE_EARNINGCATEGORY = "select * from D_EarningCategory where OID={0}";

        #region IDAL<D_EarningCategoryObject> 成员

        public void Create(D_EarningCategoryObject obj)
        {
            throw new NotImplementedException();
        }

        public void Delete(D_EarningCategoryObject obj)
        {
            throw new NotImplementedException();
        }

        public void Update(D_EarningCategoryObject obj)
        {
            throw new NotImplementedException();
        }

        public IList<D_EarningCategoryObject> QueryAll()
        {
            IList<D_EarningCategoryObject> list = new List<D_EarningCategoryObject>();
            DataTable dtD_EarningCategory = new DataTable("D_EarningCategory");
            DBHelper.FillData(SQL_SELECT_EARNINGCATEGORY, dtD_EarningCategory);
            foreach (DataRow item in dtD_EarningCategory.Rows)
            {
                D_EarningCategoryObject o = new D_EarningCategoryObject();
                o.Data2Object(item);
                list.Add(o);
            }
            return list;
        }

        public D_EarningCategoryObject Get(object id)
        {
            D_EarningCategoryObject o = new D_EarningCategoryObject();
            DataTable dtD_EarningCategory = new DataTable("D_EarningCategory");
            DBHelper.FillData(string.Format(SQL_SELECT_EARNINGCATEGORY,id), dtD_EarningCategory);
            foreach (DataRow item in dtD_EarningCategory.Rows)
            {
                o.Data2Object(item);
            }
            return o;
        }

        #endregion
    }
}
